<template>
    <transition name="slider">
        <div class="vip">
            <m-header :canreturn=true :titleText="titleText"></m-header>
            <div class="tablebox">
                <table class="table">
                    <thead>
                        <th>会员等级</th>
                        <th>积分条件</th>
                        <th>积分奖励</th>
                        <th>支付特权</th>
                    </thead>
                    <tbody>
                        <tr class="tr">
                            <td>VIP1</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP2</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP3</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP4</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP5</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP6</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                        <tr class="tr">
                            <td>VIP7</td>
                            <td>>0</td>
                            <td>0</td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="invite">
                <p>邀请好友</p>
                <div class="link">
                    <span class="share" ref="share"> http://www.yxorange.com</span>
                    <span class="copy" @click="copyLink">复制</span>
                </div>
                <div class="tips">
                    复制已上链接分享给好友, 可获得积分奖励
                </div>
            </div>
            <div class="invite">
                <p>游戏保值</p>
                <div style="font-size:16px;color:#555555;margin-top:10px;">
                    改功能仅开放于V11的用户,请联系客服
                </div>
            </div>
        </div>
    </transition>
</template>

<script type="text/ecmascript-6">
import MHeader from '@/components/m-header/m-header';
import Clipboard from 'clipboard';

export default {
    data() {
        return {
            titleText: '会员特权',
        };
    },
    methods: {
        copyLink() {
            let shareLink = this.$refs.share.textContent;
            let clipboard = new Clipboard('.copy', {
                text: () => {
                    console.log(shareLink);
                    return shareLink;
                },
            });
            clipboard.on('success', () => {
                this.showTips('复制成功');
                clipboard.destroy();
            });
            clipboard.on('error', () => {
                this.showTips('复制失败');
            });
        },
        showTips(content) {
            plus.nativeUI.toast(content);
        },
    },
    components: {
        MHeader,
    },
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
@import '~common/stylus/variable';
@import '~common/stylus/mixin';

slider();

.vip {
    position: fixed;
    width: 100%;
    top: 0;
    bottom: 0;
    background: #ffffff;

    .tablebox {
        .table {
            width: 100%;
            display: block;

            thead {
                display: flex;
                width: 100%;

                th {
                    display: block;
                    width: 25%;
                    height: 44px;
                    text-align: center;
                    background: #eeeeee;
                    line-height: 44px;
                    color: #555555;
                    box-sizing: border-box;

                    &:nth-child(2) {
                        background: #f3f3f3;
                    }

                    &:nth-child(4) {
                        background: #f3f3f3;
                    }
                }
            }

            tbody {
                display: block;
                width: 100%;

                tr {
                    display: flex;
                    border-bottom: 1px solid #d6d6d6;
                    height: 44px;
                    width: 100%;
                    color: #777777;

                    &:first-child {
                        border-top: 1px solid #d6d6d6;
                    }

                    td {
                        flex: 1;
                        height: 44px;
                        text-align: center;
                        line-height: 44px;
                        border-right: 1px solid #d6d6d6;

                        &:last-child {
                            border: none;
                        }
                    }
                }
            }
        }

        .scorewrapper {
            height: 100%;
            overflow: hidden;
        }
    }

    .invite {
        padding: 0 15px;

        p {
            font-size: $font-size-large;
            color: #222222;
            margin: 16px 0 8px 0;
        }

        .link {
            position: relative;
            height: 40px;
            width: 100%;
            padding-left: 20px;
            background: #eeeeee;
            color: #555555;
            line-height: 40px;
            box-sizing: border-box;

            .share {
                display: block;
                height: 100%;
                width: 70%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .copy {
                display: block;
                width: 60px;
                height: 30px;
                background: #f19e02;
                color: #ffffff;
                text-align: center;
                line-height: 30px;
                position: absolute;
                right: 15px;
                top: 50%;
                transform: translate3d(0, -50%, 0);
            }
        }

        .tips {
            margin-top: 5px;
            color: #f71818;
            font-size: $font-size-small;
        }
    }

    .loading-container {
        loading();
        z-index: 99999;
    }

    .tip {
        position: absolute;
        left: 50%;
        bottom: 100px;
        transform: translate3d(-50%, 0, 0);
        font-size: 12px;
        padding: 8px 10px;
        background: #797979;
        border-radius: 14px;
        color: #ffffff;
        // transition: all 3s;
    }
}
</style>
